<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <title></title>  <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
    <% include("/_view/common/include.html"){}%>
    <link href="/res/css/common.css" rel="stylesheet" type="text/css"/>
    <link href="/res/css/input.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="https://static.9hive.cn/mmenu/assets/css/site.min.css?v2.2.0"><!--common-->
    <link rel="stylesheet" href="https://static.9hive.cn/global/vendor/nprogress/nprogress.min.css"><!--common-->
    <link rel="stylesheet" href="https://static.9hive.cn/global/iconhive/hiveicon.css"><!--图标文字-->
    <link rel="stylesheet" href="https://static.9hive.cn/global/vendor/inside/inside.css?v=1"><!--common-->
    <link rel="stylesheet" href="https://static.9hive.cn/global/vendor/swiper-tab/colorfulTab.css?v=1.0.2"><!--选项卡-->
    <link rel="stylesheet" href="https://static.9hive.cn/global/vendor/common/common_20170925.css"><!--common-->

    <style type="text/css">
        .specificationSelect {
            height: 100px;
            padding: 5px;
            overflow-y: scroll;
            border: 1px solid #cccccc;
        }

        .specificationSelect li {
            float: left;
            min-width: 150px;
            _width: 200px;
        }

        td > input {
            height: 32px;
            padding: 1px 8px !important
        }

        body{
            height: auto!important;
        }
    </style>
</head>
<body>
<div class="ibox">
    <div class="ibox-title">
        <div class="pull-left mbx navbar_title">
            <span class="current">商城管理111</span>
            <span class="line">/</span>
            <span class="current"><a href="list">商品列表</a></span><span class="line">/</span>
            添加商品
        </div>
    </div>
    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="padding-10">
                    <form class="form-horizontal form-validate" method="post" id="form" action="save" enctype="multipart/form-data">
                        <input type="hidden" name="product.id" value="${product.id!}"/>
                        <input type="hidden" name="product.htmlFilePath" value="${product.htmlFilePath!}"/>
                        <input type="hidden" name="product.freezeStore" value="${product.freezeStore!0}"/>
                        <input type="hidden" name="product.specificationtype" value="${product.specificationtype!''}"/>
                        <ul class="tab">
                            <li>
                                <input type="button" value="基本信息" hidefocus="true"/>
                            </li>
                            <li>
                                <input type="button" value="商品描述" hidefocus="true"/>
                            </li>
                            <li>
                                <input type="button" value="商品规格" hidefocus="true"/>
                            </li>
                           <!-- <li>
                                <input type="button" value="商品属性" hidefocus="true"/>
                            </li>-->
                        </ul>
                        <table class="input tabContent">

                            <tr>
                                <th>
                                    <span class="maroon">*</span>商品名称:
                                </th>
                                <td>
                                    <input type="text" name="product.name" class="formText" value="${product.name!}" required/>
                                </td>
                            </tr>
                            <!--<tr>
                                <th>
                                    副标题:
                                </th>
                                <td>
                                    <input type="text" class="formText" name="product.secondName" value="${product.secondName!}"/>
                                </td>
                            </tr>-->
                            <tr>
                                <th>
                                    商品型号:
                                </th>
                                <td>
                                    <input type="text" class="formText" name="product.productSn" value="${product.productSn!}" title="若留空则由系统随机生成"/>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <span class="maroon">*</span>商品分类:
                                </th>
                                <td>
                                    <select name="product.productCategory_id" class="" required>
                                        <option value="">请选择...</option>
                                            <%for(list in productCategoryTreeList!){%>
                                                <option value="${list.id}"
                                                <%if (list.id == product.productCategory_id!){%> selected<%}%>>
                                                <%if (list.level != 0){%>
                                                <%for( i in range(0,list.level)){%>------<%}%>
                                            <%}%>
                                        ${list.name}
                                        </option>
                                        <%}%>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <span class="maroon"></span>商品品牌:
                                </th>
                                <td>
                                    <select name="product.brand_id" class="" >
                                        <option value="">请选择...</option>
                                        <%for(list in allBrand){%>
                                        <option value="${list.id}"
                                        <%if (list.id == product.brand_id!){%> selected <%}%>>
                                        ${list.name}
                                        </option>
                                        <%}%>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label class="requireField">*</label>本店售价:
                                </th>
                                <td>
                                    <input type="number" name="product.price" class="formText" value="${product.price!0}" required/>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label class="requireField">*</label>市场售价:
                                </th>
                                <td>
                                    <input type="number" name="product.marketPrice" class="formText" value="${product.marketPrice!0}" required/>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label class="requireField">*</label>商品重量:
                                </th>
                                <td>
                                    <input type="text" name="product.weight" class="formText" value="${product.weight!0}" title="0表示不计重量" required min="0"/>
                                    <select name="weightUnit">
                                        <%for(list in allWeightUnit){%>
                                            <option value="${list}">
                                                <%if (list == product.weightUnit!){%> selected <%}%>
                                                ${i18n("WeightUnit."+list)}
                                            </option>
                                        <%}%>
                                    </select>
                                    <span id="weightMessagePosition"></span>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label class="requireField">*</label>库存量:
                                </th>
                                <td>
                                    <input type="text" name="product.store" class="formText" value="0" title="只允许输入零或正整数，为空表示不计库存" required min="0"/>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label class="requireField">*</label>购买基数:
                                </th>
                                <td>
                                    <input type="text" name="product.basebuy" class="formText" value="${product.basebuy!0}" title="只允许输入零或正整数" required min="0"/>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label class="requireField">*</label>页面排序号:
                                </th>
                                <td>
                                    <input type="text" name="product.sortNo" value="${product.sortNo!'50'}" required/>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    是否精品推荐:
                                </th>
                                <td>
                                    <label><input type="radio" name="product.isBest" value="true"/>是</label>
                                    <label><input type="radio" name="product.isBest" value="false" checked />否</label>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    是否新品推荐:
                                </th>
                                <td>
                                    <label><input type="radio" name="product.isNew" value="true"/>是</label>
                                    <label><input type="radio" name="product.isNew" value="false"checked />否</label>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    是否热销推荐:
                                </th>
                                <td>
                                    <label><input type="radio" name="product.isHot" value="true"/>是</label>
                                    <label><input type="radio" name="product.isHot" value="false" checked/>否</label>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    是否特惠商品:
                                </th>
                                <td>
                                    <label><input type="radio" name="product.isCheap" value="true"/>是</label>
                                    <label><input type="radio" name="product.isCheap" value="false" checked/>否</label>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    是否上架:
                                </th>
                                <td>
                                    <label><input type="radio" name="product.isMarketable" value="true" />是</label>
                                    <label><input type="radio" name="product.isMarketable" value="false" checked/>否</label>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    背景图:
                                </th>
                                <td>
                                    <input type="hidden" name="product.backGroundImg" value="" class="pull-left form-control light-input"/>
                                    <img class="img-rounded" src="${product.backGroundImg!}" style="max-height:50px;"/>
                                    <input type="button" class="button browserButton" value="选择文件"/>
                                    <span class="help-block"><span class="maroon"></span>建议400*600,小于1M,像素格式jpg</span>
                                </td>
                            </tr>


                            <tr>
                                <th>
                                    上传商品图片
                                </th>
                                <td>
                                    <div class="productImageArea">
                                        <div class="example" style="margin-top: 0px"></div>
                                        <a class="prev browse" href="javascript:void(0);" hidefocus="true"></a>
                                        <div class="scrollable">
                                            <ul class="items">
                                                <%for(list in product.productImageList!){%>
                                                <li>
                                                    <div class="productImageBox">
                                                        <div class="productImagePreview png">
                                                            <img src="${list.thumbnailProductImagePath}" alt=""/>
                                                        </div>
                                                        <div class="productImageOperate">
                                                            <a class="left" href="javascript: void(0);" alt="左移"
                                                               hidefocus="true"></a>
                                                            <a class="right" href="javascript: void(0);" title="右移"
                                                               hidefocus="true"></a>
                                                            <a class="delete" href="javascript: void(0);" title="删除"
                                                               hidefocus="true"></a>
                                                        </div>
                                                        <a class="productImageUploadButton" href="javascript: void(0);">
                                                            <input type="hidden" name="productImageIds"
                                                                   value="${list.id}"/>
                                                            <input type="hidden" name="productImageParameterTypes"
                                                                   value="productImageId"/>
                                                            <%if (systemConfig.allowedUploadImageExtension != ""){%>
                                                            <input type="file" name="productImages" hidefocus="true"/>
                                                            <div>上传新图片</div>
                                                            <%}else{%>
                                                            <div>不允许上传</div>
                                                            <%}%>
                                                        </a>
                                                    </div>
                                                </li>
                                                <%}%>
                                                <li>
                                                    <div class="productImageBox">
                                                        <div class="productImagePreview png">暂无图片</div>
                                                        <div class="productImageOperate">
                                                            <a class="left" href="javascript: void(0);" alt="左移"
                                                               hidefocus="true"></a>
                                                            <a class="right" href="javascript: void(0);" title="右移"
                                                               hidefocus="true"></a>
                                                            <a class="delete" href="javascript: void(0);" title="删除"
                                                               hidefocus="true"></a>
                                                        </div>
                                                        <a class="productImageUploadButton" href="javascript: void(0);">
                                                            <%if (systemConfig.allowedUploadImageExtension != ""){%>
                                                            <input type="file" name="productImages_1" hidefocus="true"/>
                                                            <div>上传新图片</div>
                                                            <%}else{%>
                                                            <div>不允许上传</div>
                                                            <%}%>
                                                        </a>
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                        <span class="next browse" href="javascript:void(0);" hidefocus="true"></span>
                                        <div class="blank"></div>
                                        <%if (systemConfig.allowedUploadImageExtension != ""){%>
                                        <span class="warnInfo"><span class="icon">&nbsp;</span>
                                            单张图片大小不能超过500K,最多上传5张
                                            <%for(list in strutil.split(systemConfig.allowedUploadImageExtension,@cn.szzsi.common.bean.SystemConfig.EXTENSION_SEPARATOR)){%>
                                                <%if (listLP.last){%>
                                                    *.${list};
                                                <%}else{%>
                                                    *.${list}
                                                <%}%>
                                            <%}%>
                                        </span>
                                        <%}else{%>
                                        <span class="warnInfo"><span class="icon">&nbsp;</span>系统设置不允许上传图片文件!</span>
                                        <%}%>
                                    </div>
                                </td>
                            </tr>
                            <!--<tr>
                                <th>
                                    页面关键词:
                                </th>
                                <td>
                                    <input type="text" name="product.metaKeywords" class="formText"
                                           value="${product.metaKeywords!}"/>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    页面描述:
                                </th>
                                <td>
                                    <textarea name="product.metaDescription" class="formTextarea">${product.metaDescription!}</textarea>
                                </td>
                            </tr>-->
                        </table>
                        <table class="input tabContent">
                            <!--<tr>
                                <th>
                                    视频file_id:
                                </th>
                                <td>
                                    <input type="text" name="product.videoFileId" class="formText"
                                           value="${product.videoFileId!}"/>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    视频app_id:
                                </th>
                                <td>
                                    <input type="text" class="formText" name="product.videoAppId"
                                           value="${product.videoAppId!}"/>
                                </td>
                            </tr>-->
                            <tr>
                                <th>
                                    描述:
                                </th>
                                <td colspan="2">
                                    <textarea id="personInfo" name="product.description" rows="10" style="width: 100%">${product.description!}</textarea>
                                    <!--<textarea name="product.description" class="wysiwyg" style="width: 100%; height: 450px;">${product.description!}</textarea>-->
                                </td>
                            </tr>
                        </table>
                        <table class="input tabContent">
                            <tr >
                                <td style="display: none">
                                    是否分sku显示:
                                    <select name="product.isShowSku">
                                        <option value="false" selected="">否</option>
                                        <option value="true">是</option>
                                    </select>
                                </td>
                            </tr>
                            <tr class="title">
                                <th>
                                    请选择商品规格:
                                </th>
                            </tr>
                            <tr>
                                <td>
                                    <div id="specificationSelect" class="specificationSelect">
                                        <ul>
                                            <%for(s in allSpecification){ %>
                                            <li>
                                                <label>
                                                    <input type="checkbox" name="specificationIds" value="${s.id}"
                                                    <%if(!isEmpty(product.specificationids) &&
                                                    strutil.contain(product.specificationids,s.id)){%>
                                                    checked="checked"<%}%> />${s.name}
                                                    <span class="gray">[${s.memo}]</span>
                                                </label>
                                            </li>
                                            <%}%>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <a href="javascript:;" id="addSpecificationProduct" class="button">增加规格商品</a>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <table id="specificationProductTable" class="input">
                                        <tr class="title">
                                            <td width="60">
                                                &nbsp;
                                            </td>
                                            <%for(s in allSpecification){ %>
                                            <td class="specification_${s.id} <%if(isEmpty(product.specificationids) || !strutil.contain(product.specificationids!,s.id!)){%>hidden<%}%>">
                                                ${s.name}
                                                <span class="gray">[${s.memo}]</span>
                                            </td>
                                            <%}%>
                                            <td>
                                                价格
                                            </td>
                                            <td>
                                                库存
                                            </td>
                                            <td>
                                                操作
                                            </td>
                                        </tr>
                                        <tr class="hidden">
                                            <td>
                                                &nbsp;
                                            </td>
                                            <%for(s in allSpecification){ %>
                                            <td class="specification_${s.id} <%if(isEmpty(product.specificationids) || !strutil.contain(product.specificationids!,s.id!)){%>hidden<%}%>">
                                                <select name="specification_${s.id}" disabled="disabled">
                                                    <%for(ss in s.specificationValues){ %>
                                                    <option value="${ss.id}">${ss.name}</option>
                                                    <%}%>
                                                </select>
                                            </td>
                                            <%}%>
                                            <td>
                                                <input type="text" class="formText" name="specificationPrice" value="0" style="width: 41px;height: 19px" required/>
                                            </td>
                                            <td>
                                                <input type="text" class="formText" name="specificationStore" value="0" style="width: 41px;height: 19px"/>
                                            </td>
                                            <td>
                                                <a href="javascript:;" class="deleteSpecificationProduct">[删除]</a>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                        <table class="input tabContent">
                            <tr id="productTypeTr">
                                <th>
                                    商品类型:
                                </th>
                                <td>
                                    <select name="product.productType_id" id="productTypeId">
                                        <option value="">请选择...</option>
                                        <%for(list in allProductType){%>
                                        <option value="${list.id}">${list.name}</option>
                                        <%}%>
                                    </select>
                                </td>
                            </tr>
                            <%for(list in product.productType.enabledProductAttributeList!){%>
                            <tr class="productAttributeContentTr">
                                <th>
                                    ${list.name}:
                                </th>
                                <td>
                                    <%if (list.attributeTypeValue == "text"){%>
                                    <input type="text" name="${list.id}"
                                           class="formText<%if (list.isRequired){%> {required: true}<%}%>"
                                           value="${product.productAttributeMap[list.id]!}"/>
                                    <%if (list.isRequired){%><label class="requireField">*</label><%}%>
                                    <%}else if (list.attributeTypeValue == "number"){%>
                                    <input type="text" name="${list.id}"
                                           class="formText {<%if (list.isRequired){%>required: true, <%}%>number: true}"
                                           value="${product.productAttributeMap[list.id]!}"/>
                                    <%if (list.isRequired){%><label class="requireField">*</label><%}%>
                                    <%}else if (list.attributeTypeValue == "alphaint"){%>
                                    <input type="text" name="${list.id}"
                                           class="formText {<%if (list.isRequired){%>required: true, <%}%>lettersonly: true}"
                                           value="${product.productAttributeMap[list.id]!}"/>
                                    <%if (list.isRequired){%><label class="requireField">*</label><%}%>
                                    <%}else if (list.attributeTypeValue == "select"){%>
                                    <select name="${list.id}"<%if (list.isRequired){%> class="{required: true}"<%}%>>
                                    <option value="">请选择...</option>
                                    <%for(attributeOptionList in list.attributeOptionList){%>
                                    <option value="${attributeOptionList}"
                                    <%if (product.productAttributeMap[list.id] == attributeOptionList){%>
                                    selected<%}%>>${attributeOptionList}</option>
                                    <%}%>
                                    </select>
                                    <%if (list.isRequired){%><label class="requireField">*</label><%}%>
                                    <%}else if (list.attributeTypeValue == "checkbox"){%>
                                    <%for(attributeOptionList in list.attributeOptionList){%>
                                    <label><input type="checkbox" name="${list.id}"<%if (list.isRequired){%>
                                        class="{required: true, messagePosition: '#${list.id}MessagePosition'}"<%}%>
                                        value="${attributeOptionList}"<%if
                                        (strutil.contain(product.productAttributeMap[list.id],attributeOptionList)){%>
                                        checked<%}%> />${attributeOptionList}</label>
                                    <%}%>
                                    <span id="${list.id}MessagePosition"></span>
                                    <%if (list.isRequired){%><label class="requireField">*</label><%}%>
                                    <%}else if (list.attributeTypeValue == "date"){%>
                                    <input type="text" name="${list.id}"
                                           class="formText datePicker {<%if (list.isRequired){%>required: true, <%}%>dateISO: true}"
                                           value="${product.productAttributeMap[list.id]!}"/>
                                    <%if (list.isRequired){%><label class="requireField">*</label><%}%>
                                    <%}%>
                                </td>
                            </tr>
                            <%}%>
                        </table>
                        <div class="buttonArea" style="margin-left: 165px;margin-top: 5px;margin-bottom: 40px">
                            <input type="button" id="submitbutton" class="button" value="确  定" hidefocus="true"/>&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="button" class="button" onclick="location.href='list';" value="返  回" hidefocus="true"/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://static.9hive.cn/global/vendor/nprogress/nprogress.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-3.3.7/bootstrap.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-validate/localization/messages_zh.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-ajaxform/ajax-form.js"></script>

<!--kindEditor-->
<script src="/res/plugins/kindeditor-4.1.10/kindeditor-all-min.js"></script>
<script src="https://static.9hive.cn/global/vendor/kindeditor/lang/zh-CN.js"></script>
<script type="text/javascript">
    KindEditor.ready(function (K) {
        personInfoeditor = K.create("#personInfo", {
            themeType: 'simple',
            allowFileManager: true,
            width: "80%",
            height: "260px",
            uploadJson: '/file/uploadfile?shopId=${shopId!}&type=k',
            fileManagerJson: '/file/fileManagerJson?shopId=${shopId!}'
        });
    });
</script>
<!-- 自定义js -->
<script src="https://static.9hive.cn/global/vendor/file/uploadify/jquery_uploadify.js"></script><!--上传-->
<script src="https://static.9hive.cn/global/vendor/icheck/icheck.min.js"></script><!--common-->

<script src="https://static.9hive.cn/global/vendor/layer/layer.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-validate/jquery.validate.min.js"></script><!--common-->
<script src="https://static.9hive.cn/global/vendor/jquery-validate/additional-methods.min.js"></script><!--common-->
<script src="https://static.9hive.cn/global/vendor/jquery-validate/localization/messages_zh.min.js"></script><!--common-->
<script src="https://static.9hive.cn/global/vendor/inside/inside20170925.js"></script><!--common-->
<script src="https://static.9hive.cn/global/vendor/jquery-ajaxform/ajax-form.js"></script><!--common-->

<script type="text/javascript">

    $().ready(function () {
        var $inputForm = $("#submitbutton");
        var $addSpecificationProduct = $("#addSpecificationProduct");
        var $specificationIds = $("#specificationSelect :checkbox");
        var $specificationProductTable = $("#specificationProductTable");
        var $deleteSpecificationProduct = $("a.deleteSpecificationProduct");


        // 修改商品规格
        $specificationIds.click(function () {
            if ($specificationIds.filter(":checked").size() == 0) {
                $specificationProductTable.find("tr:gt(1)").remove();
            }
            var $this = $(this);
            if ($this.prop("checked")) {
                $specificationProductTable.find("td.specification_" + $this.val()).show().find("select").prop("disabled", false);
            } else {
                $specificationProductTable.find("td.specification_" + $this.val()).hide().find("select").prop("disabled", true);
            }
        });
        // 增加规格商品
        $addSpecificationProduct.click(function () {
            if ($specificationIds.filter(":checked").size() == 0) {
                //$.message("warn", "必须至少选择一个规格");
                layer.msg("必须至少选择一个规格");
                return false;
            }
            if ($specificationProductTable.find("tr:gt(1)").size() == 0) {
                $tr = $specificationProductTable.find("tr:eq(1)").clone().show().appendTo($specificationProductTable);
                $tr.find("td:first").text("当前规格");
                $tr.find("td:last").text("-");
            } else {
                $specificationProductTable.find("tr:eq(1)").clone().show().appendTo($specificationProductTable);
            }
        });


        // 删除规格商品
        $deleteSpecificationProduct.live("click", function () {
            var $this = $(this);
            $.dialog({
                type: "warn",
                content: "您确定要删除吗？",
                onOk: function () {
                    $this.closest("tr").remove();
                }
            });
        });

        $inputForm.on('click', function (form) {
            if ($specificationIds.filter(":checked").size() > 0 && $specificationProductTable.find("tr:gt(1)").size() == 0) {
                //$.message("warn", "必须至少添加一个规格商品");
                layer.msg("必须至少添加一个规格商品!");
                return false;
            } else {
                var isRepeats = false;
                var parameters = new Array();
                $specificationProductTable.find("tr:gt(1)").each(function () {
                    var parameter = $(this).find("select").serialize();
                    if ($.inArray(parameter, parameters) >= 0) {
                        layer.msg("商品规格值重复");
                        isRepeats = true;
                        return false;
                    } else {
                        parameters.push(parameter);
                    }
                });
                if (!isRepeats) {
                    $specificationProductTable.find("tr:eq(1)").find("select").prop("disabled", true);
                    $specificationProductTable.find("tr:eq(1)").find("input").prop("disabled", true);
                    $('#form').submit();
                }
            }
        });
    });

</script>
<script type="text/javascript">
    $().ready(function () {
        // 查询商品属性
        $("#productTypeId").change(function () {
            $(".productAttributeContentTr").remove();
            var productTypeId = $("#productTypeId").val();
            $.ajax({
                url: "/mall/admin/productAttribute/ajaxProductAttribute",
                dataType: "json",
                data: {productTypeId: productTypeId},
                async: false,
                success: function (json) {
                    var productAttributeTrHtml = "";
                    $.each(json, function (i) {
                        if (json[i]["attributeType"] == 0) {
                            productAttributeTrHtml += '<tr class="productAttributeContentTr"><th>' + json[i].name + ':</th><td><input type="text" name="' + json[i].id + '"' + ((json[i].isRequired == true) ? ' class="formText {required: true}"' : ' class="formText"') + ' />' + ((json[i].isRequired == true) ? '<label class="requireField">*</label>' : '') + '</td></tr>';
                        } else if (json[i]["attributeType"] == 1) {
                            productAttributeTrHtml += '<tr class="productAttributeContentTr"><th>' + json[i].name + ':</th><td><input type="text" name="' + json[i].id + '"' + ((json[i].isRequired == true) ? ' class="formText {required: true, number: true}"' : ' class="formText {number: true}"') + ' />' + ((json[i].isRequired == true) ? '<label class="requireField">*</label>' : '') + '</td></tr>';
                        } else if (json[i]["attributeType"] == 2) {
                            productAttributeTrHtml += '<tr class="productAttributeContentTr"><th>' + json[i].name + ':</th><td><input type="text" name="' + json[i].id + '"' + ((json[i].isRequired == true) ? ' class="formText {required: true, lettersonly: true}"' : ' class="formText {lettersonly: true}"') + ' />' + ((json[i].isRequired == true) ? '<label class="requireField">*</label>' : '') + '</td></tr>';
                        } else if (json[i]["attributeType"] == 3) {
                            var productAttributeOption = '<option value="">请选择...</option>';
                            for (var key in json[i]["attributeOptionList"]) {
                                productAttributeOption += ('<option value="' + json[i]["attributeOptionList"][key] + '">' + json[i]["attributeOptionList"][key] + '</option>');
                            }
                            productAttributeTrHtml += '<tr class="productAttributeContentTr"><th>' + json[i].name + ':</th><td><select name="' + json[i].id + '"' + ((json[i].isRequired == true) ? ' class="{required: true}"' : '') + '>' + productAttributeOption + '</select>' + ((json[i].isRequired == true) ? '<label class="requireField">*</label>' : '') + '</td></tr>';
                        } else if (json[i]["attributeType"] == 4) {
                            var productAttributeOption = "";
                            for (var key in json[i]["attributeOptionList"]) {
                                productAttributeOption += ('<label><input type="checkbox" name="' + json[i].id + '" value="' + json[i]["attributeOptionList"][key] + '"' + ((json[i].isRequired == true) ? ' class="{required: true, messagePosition: \'#' + json[i].id + 'MessagePosition\'}"' : '') + ' />' + json[i]["attributeOptionList"][key] + '</label>&nbsp;&nbsp;');
                            }
                            productAttributeTrHtml += '<tr class="productAttributeContentTr"><th>' + json[i].name + ':</th><td>' + productAttributeOption + ((json[i].isRequired == true) ? '<span id="' + json[i].id + 'MessagePosition"></span><label class="requireField">*</label>' : '') + '</td></tr>';
                        } else if (json[i]["attributeType"] == 5) {
                            productAttributeTrHtml += '<tr class="productAttributeContentTr"><th>' + json[i].name + ':</th><td><input type="text" name="' + json[i].id + '"' + ((json[i].isRequired == true) ? ' class="formText datePicker {required: true, dateISO: true}"' : ' class="formText datePicker {dateISO: true}"') + ' />' + ((json[i].isRequired == true) ? '<label class="requireField">*</label>' : '') + '</td></tr>';
                        }
                    })
                    $("#productTypeTr").after(productAttributeTrHtml);
                    $.bindDatePicker();
                }
            });
        });

        // 商品图片预览滚动栏
        $(".productImageArea .scrollable").scrollable({
            speed: 600
        });

        // 显示商品图片预览操作层
        $(".productImageArea li").livequery("mouseover", function () {
            $(this).find(".productImageOperate").show();
        });

        // 隐藏商品图片预览操作层
        $(".productImageArea li").livequery("mouseout", function () {
            $(this).find(".productImageOperate").hide();
        });

        // 商品图片左移
        $(".left").livequery("click", function () {
            var $productImageLi = $(this).parent().parent().parent();
            var $productImagePrevLi = $productImageLi.prev("li");
            if ($productImagePrevLi.length > 0) {
                $productImagePrevLi.insertAfter($productImageLi);
            }
        });

        // 商品图片右移
        $(".right").livequery("click", function () {
            var $productImageLi = $(this).parent().parent().parent();
            var $productImageNextLi = $productImageLi.next("li");
            if ($productImageNextLi.length > 0) {
                $productImageNextLi.insertBefore($productImageLi);
            }
        });

        // 商品图片删除
        $(".delete").livequery("click", function () {
            var $productImageLi = $(this).parent().parent().parent();
            var $productImagePreview = $productImageLi.find(".productImagePreview");
            var $productImageIds = $productImageLi.find("input[name='productImageIds']");
            var $productImageFiles = $productImageLi.find("input[name='productImages']");
            var $productImageParameterTypes = $productImageLi.find("input[name='productImageParameterTypes']");
            $productImageIds.remove();
            $productImageFiles.after('<input type="file" name="productImages" hidefocus="true" />');
            $productImageFiles.remove();
            $productImageParameterTypes.remove();

            $productImagePreview.html("暂无图片");
            $productImagePreview.removeAttr("title");
            if ($.browser.msie) {
                if (window.XMLHttpRequest) {
                    $productImagePreview[0].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = 'scale', src='')";
                }
            }
        });

        // 商品图片选择预览
        var $productImageScrollable = $(".productImageArea .scrollable").scrollable();
        var productImageLiHtml = '<li><div class="productImageBox"><div class="productImagePreview">暂无图片</div><div class="productImageOperate"><a class="left" href="javascript: void(0);" alt="左移" hidefocus="true"></a><a class="right" href="javascript: void(0);" title="右移" hidefocus="true"></a><a class="delete" href="javascript: void(0);" title="删除" hidefocus="true"></a></div><a class="productImageUploadButton" href="javascript: void(0);"><input type="file" name="productImages" hidefocus="true" /><div>上传新图片</div></a></div></li>';
        var index = 0;
        $(".productImageUploadButton input").livequery("change", function () {
            var $this = $(this);
            var $productImageLi = $this.parent().parent().parent();
            var $productImagePreview = $productImageLi.find(".productImagePreview");
            var fileName = $this.val().substr($this.val().lastIndexOf("\\") + 1);
            if (/(<%for(list in strutil.split(systemConfig.allowedUploadImageExtension,@cn.szzsi.common.bean.SystemConfig.EXTENSION_SEPARATOR)){%><%if (!listLP.last){%>.${list}|<%}else{%>.${list}<%}%><%}%>)$/i.test($this.val()) == false) {
                //$.message("您选择的文件格式错误！");
                layer.msg("您选择的文件格式错误");
                return false;
            }
            $productImagePreview.empty();
            $productImagePreview.attr("title", fileName);
            var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;//判断是否是谷歌浏览器
            if ($.browser.msie) {
                if (!window.XMLHttpRequest) {
                    $productImagePreview.html('<img src="' + $this.val() + '" />');
                } else {
                    $this[0].select();
                    var imgSrc = document.selection.createRange().text;
                    $productImagePreview[0].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = 'scale', src='" + imgSrc + "')";
                }
            } else if ($.browser.mozilla || isChrome) {
                var objectURL = window.URL.createObjectURL($this[0].files[0]);//Firefox 7.0下getAsDataURL取文件绝对路径的替代方法
                $productImagePreview.html('<img src="' + objectURL + '" />');
                //$productImagePreview.html('<img src="' + $this[0].files[0].getAsDataURL() + '" />');
            } else {
                $productImagePreview.html(fileName);
            }

            if ($productImageLi.next().length == 0) {
                productImageLiHtml = productImageLiHtml.replace("productImages", "productImages" + index);
                $productImageLi.after(productImageLiHtml);
                index++;
                if ($productImageScrollable.getSize() > 5) {
                    $productImageScrollable.next();
                }
            }
            if ($productImageLi.next().length == 1) {
                $this.attr("name", "productImages" + index)
                index++;
                if ($productImageScrollable.getSize() > 5) {
                    $productImageScrollable.next();
                }
            }

            var $productImageIds = $productImageLi.find("input[name='productImageIds']");
            var $productImageParameterTypes = $productImageLi.find("input[name='productImageParameterTypes']");
            var $productImageUploadButton = $productImageLi.find(".productImageUploadButton");
            $productImageIds.remove();
            if ($productImageParameterTypes.length > 0) {
                $productImageParameterTypes.val("productImageFile");
            } else {
                $productImageUploadButton.append('<input type="hidden" name="productImageParameterTypes" value="productImageFile" />');
            }
        });

    })
</script>

<script type="text/javascript">
    var uploadUrl="/file/uploadfile?shopId=${shopId!}&type=d";
    var browserUrl="/file/browser?shopId=${shopId!}";
</script>
<script src="https://nsr.9hive.cn/global/vendor/file/file1229.js"></script>
<script type="text/javascript">
    $(function () {
        $("input.browserButton").browser();
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_flat-blue',
            radioClass: 'iradio_flat-blue',
        });

    })
</script>
</body>
</html>